{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "from tools.config import CONFIG"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['/home/wuxiang/data-vol-1/comptetition/mycode/tools/../../mycode/models/models_for_3_xgb']"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "folder_path = [os.path.join(CONFIG().MODEL_ROOT, i) for i in os.listdir(CONFIG().MODEL_ROOT) if 'model' in i]\n",
    "folder_path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "file_path0 = os.path.join(folder_path[0], 'performances_base.csv')\n",
    "df0 = pd.read_csv(file_path0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>场站</th>\n",
       "      <th>label</th>\n",
       "      <th>test_maxError</th>\n",
       "      <th>test_MAE</th>\n",
       "      <th>train_maxError</th>\n",
       "      <th>train_MAE</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>A</td>\n",
       "      <td>SO2_</td>\n",
       "      <td>16.086504</td>\n",
       "      <td>1.895733</td>\n",
       "      <td>5.144378</td>\n",
       "      <td>0.402662</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>A</td>\n",
       "      <td>NO2_</td>\n",
       "      <td>55.585789</td>\n",
       "      <td>8.397628</td>\n",
       "      <td>37.792862</td>\n",
       "      <td>3.137523</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>A</td>\n",
       "      <td>PM10_</td>\n",
       "      <td>61.963364</td>\n",
       "      <td>10.347288</td>\n",
       "      <td>58.491592</td>\n",
       "      <td>4.019497</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>A</td>\n",
       "      <td>PM2.5_</td>\n",
       "      <td>40.734642</td>\n",
       "      <td>6.838126</td>\n",
       "      <td>25.058441</td>\n",
       "      <td>2.350942</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>A</td>\n",
       "      <td>O3_</td>\n",
       "      <td>244.852783</td>\n",
       "      <td>19.259490</td>\n",
       "      <td>46.578476</td>\n",
       "      <td>5.189113</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0</td>\n",
       "      <td>A</td>\n",
       "      <td>CO_</td>\n",
       "      <td>0.494489</td>\n",
       "      <td>0.162305</td>\n",
       "      <td>0.448883</td>\n",
       "      <td>0.059390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0</td>\n",
       "      <td>B</td>\n",
       "      <td>SO2_</td>\n",
       "      <td>5.513485</td>\n",
       "      <td>1.667513</td>\n",
       "      <td>2.702701</td>\n",
       "      <td>0.317437</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0</td>\n",
       "      <td>B</td>\n",
       "      <td>NO2_</td>\n",
       "      <td>41.667267</td>\n",
       "      <td>6.924688</td>\n",
       "      <td>27.275261</td>\n",
       "      <td>2.300640</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0</td>\n",
       "      <td>B</td>\n",
       "      <td>PM10_</td>\n",
       "      <td>72.973000</td>\n",
       "      <td>10.636133</td>\n",
       "      <td>40.930145</td>\n",
       "      <td>3.632512</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0</td>\n",
       "      <td>B</td>\n",
       "      <td>PM2.5_</td>\n",
       "      <td>30.637974</td>\n",
       "      <td>4.263399</td>\n",
       "      <td>19.937225</td>\n",
       "      <td>1.709163</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0</td>\n",
       "      <td>B</td>\n",
       "      <td>O3_</td>\n",
       "      <td>127.960800</td>\n",
       "      <td>17.570744</td>\n",
       "      <td>55.002129</td>\n",
       "      <td>4.665308</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0</td>\n",
       "      <td>B</td>\n",
       "      <td>CO_</td>\n",
       "      <td>0.444776</td>\n",
       "      <td>0.098014</td>\n",
       "      <td>0.350515</td>\n",
       "      <td>0.050517</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0</td>\n",
       "      <td>C</td>\n",
       "      <td>SO2_</td>\n",
       "      <td>9.073081</td>\n",
       "      <td>2.247090</td>\n",
       "      <td>4.737865</td>\n",
       "      <td>0.429810</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0</td>\n",
       "      <td>C</td>\n",
       "      <td>NO2_</td>\n",
       "      <td>44.625694</td>\n",
       "      <td>7.447919</td>\n",
       "      <td>35.810989</td>\n",
       "      <td>2.482981</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0</td>\n",
       "      <td>C</td>\n",
       "      <td>PM10_</td>\n",
       "      <td>62.708876</td>\n",
       "      <td>16.037845</td>\n",
       "      <td>54.914932</td>\n",
       "      <td>4.486172</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0</td>\n",
       "      <td>C</td>\n",
       "      <td>PM2.5_</td>\n",
       "      <td>71.001854</td>\n",
       "      <td>8.069713</td>\n",
       "      <td>42.997730</td>\n",
       "      <td>3.131550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0</td>\n",
       "      <td>C</td>\n",
       "      <td>O3_</td>\n",
       "      <td>157.943909</td>\n",
       "      <td>20.495721</td>\n",
       "      <td>47.510658</td>\n",
       "      <td>5.181570</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0</td>\n",
       "      <td>C</td>\n",
       "      <td>CO_</td>\n",
       "      <td>0.623066</td>\n",
       "      <td>0.110506</td>\n",
       "      <td>0.695883</td>\n",
       "      <td>0.065650</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Unnamed: 0 场站   label  test_maxError   test_MAE  train_maxError  train_MAE\n",
       "0            0  A    SO2_      16.086504   1.895733        5.144378   0.402662\n",
       "1            0  A    NO2_      55.585789   8.397628       37.792862   3.137523\n",
       "2            0  A   PM10_      61.963364  10.347288       58.491592   4.019497\n",
       "3            0  A  PM2.5_      40.734642   6.838126       25.058441   2.350942\n",
       "4            0  A     O3_     244.852783  19.259490       46.578476   5.189113\n",
       "5            0  A     CO_       0.494489   0.162305        0.448883   0.059390\n",
       "6            0  B    SO2_       5.513485   1.667513        2.702701   0.317437\n",
       "7            0  B    NO2_      41.667267   6.924688       27.275261   2.300640\n",
       "8            0  B   PM10_      72.973000  10.636133       40.930145   3.632512\n",
       "9            0  B  PM2.5_      30.637974   4.263399       19.937225   1.709163\n",
       "10           0  B     O3_     127.960800  17.570744       55.002129   4.665308\n",
       "11           0  B     CO_       0.444776   0.098014        0.350515   0.050517\n",
       "12           0  C    SO2_       9.073081   2.247090        4.737865   0.429810\n",
       "13           0  C    NO2_      44.625694   7.447919       35.810989   2.482981\n",
       "14           0  C   PM10_      62.708876  16.037845       54.914932   4.486172\n",
       "15           0  C  PM2.5_      71.001854   8.069713       42.997730   3.131550\n",
       "16           0  C     O3_     157.943909  20.495721       47.510658   5.181570\n",
       "17           0  C     CO_       0.623066   0.110506        0.695883   0.065650"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "file_path = os.path.join(folder_path[0], 'performances.csv')\n",
    "df = pd.read_csv(file_path)\n",
    "indexs = ['test_maxError','test_MAE', 'train_maxError', 'train_MAE']\n",
    "df[indexs] = df[indexs] - df0[indexs]\n",
    "df"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
